 :root {
    --primary-color: #615ced;
    --secondary-color: #c6c4ff;
    --accent-color: #3e7510;
    --background-light: #F5F7FA;
    --text-dark: #2C3E50;
    --text-light: #6B7C8F;
    --success-color: #4CAF50;
    --error-color: #E74C3C;
    --transition-speed: 0.3s;
    --shadow-color: rgba(214, 213, 220);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background: var(--background-light);
    color: var(--text-dark);
}

.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    background-size: 200% 200%;
    color: white;
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: 0 2px 15px var(--shadow-color);
    z-index: 1000;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.nav-item {
    margin-left: 2rem;
    cursor: pointer;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-item:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
}

 .submit-btn .loader {
     width: 18px;
     height: 18px;
     border-width: 2px;
     margin-right: 8px;
 }

.container {
    margin-top: 80px;
    padding: 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.upload-section {
    background: rgba(255,255,255,0.95);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 20px var(--shadow-color);
}

.file-upload {
    border: 2px dashed #e0e0e0;
    padding: 3rem 2rem;
    text-align: center;
    border-radius: 12px;
    margin-bottom: 2rem;
    transition: all var(--transition-speed);
    background: #fcfcfc;
    cursor: pointer;
}

.file-upload:hover {
    border-color: var(--primary-color);
    background: rgba(46, 139, 135, 0.03);
}

 .file-upload.dragover {
     border-color: var(--success-color);
     background: rgba(76, 175, 80, 0.05);
 }

.kb-name-input {
    width: 100%;
    padding: 1rem;
    margin: 0.5rem 0;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.kb-name-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 139, 135, 0.2);
}

.submit-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color));
    color: white;
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 15px var(--shadow-color);
}

.submit-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(46, 139, 135, 0.25);
}

 .analysis-results {
     margin-top: 2rem;
     display: flex;
     flex-direction: column;
     gap: 2rem;
 }

 .document-info {
    background: rgba(255,255,255,0.95);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(46, 139, 135, 0.1);
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

 .info-item {
     display: flex;
     flex-direction: column;
     min-width: 120px;
     padding: 0 1rem;
     border-right: 1px solid #eee;
 }

 .info-item:last-child {
     border-right: none;
 }

.info-item h4 {
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.info-item p {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 500;
}

.chat-container {
    background: rgba(245,246,250,0.8);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px var(--shadow-color);
    height: calc(100vh - 160px);
    display: flex;
    flex-direction: column;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background: rgba(245,246,250,0.8);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

 .notification {
     position: fixed;
     top: 20px;
     right: 20px;
     background: rgba(255,255,255,0.95);
     padding: 1.25rem 2rem;
     border-radius: 8px;
     box-shadow: 0 4px 20px rgba(0,0,0,0.88);
     display: flex;
     align-items: center;
     gap: 1.25rem;
     transform: translateX(120%);
     transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
     z-index: 9999;
     border: 1px solid #eee;
 }

 .notification.show {
     transform: translateX(0);
 }

 .notification.error {
     border-left: 4px solid #ff4444;
 }

 .notification.success {
     border-left: 4px solid var(--success-color);
 }

 .notification-icon {
     width: 24px;
     height: 24px;
     flex-shrink: 0;
 }

.message {
    display: flex;
    align-items: start;
    margin: 1.5rem 0;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    position: relative;
    max-width: 80%;
    width: fit-content;
}

.progress-bar {
    margin-top: 30px;
}

.message-logo {
    width: 20px;
    height: 20px;
    position: absolute;
    top: 8px;
    background: #FAFAFACC;
    margin-left: -14px;
}

.bot-message .message-logo {
    background: #FAFAFACC;
    left: -20px;
}

.message-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.user-message {
    background: #E0DFFC;
    margin-left: auto;
    flex-direction: row-reverse;
    border-radius: 16px 0 16px 16px;
}


.user-message:hover {
    transform: translateX(5px);
    transition: transform 0.2s ease;
}

.bot-message:hover {
    transform: translateX(-5px);
    transition: transform 0.2s ease;
}

.message:hover .message-logo {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}



 @keyframes messageAppear {
     from {
         opacity: 0;
         transform: translateY(10px);
     }
     to {
         opacity: 1;
         transform: translateY(0);
     }
 }


.bot-message {
    background: #FFFFFF;
    margin-right: auto;
    margin-left: 2%;
    flex-direction: row;
    border-radius: 0 16px 16px 16px;
}

 .chat-input {
     display: flex;
     gap: 1rem;
     align-items: center;
 }

 .chat-textarea {
     flex: 1;
     padding: 1rem 1.5rem;
     border: 2px solid #eee;
     border-radius: 12px;
     resize: none;
     min-height: 48px;
     transition: all var(--transition-speed);
 }

 .chat-textarea:focus {
     border-color: var(--primary-color);
     box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
     outline: none;
 }

 .send-btn {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-color));
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.send-btn:hover {
    background: linear-gradient(135deg, #3DA09B, #5A8FB4);
    transform: scale(1.05);
}

.kb-selector {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    background:
        linear-gradient(145deg, rgba(255,255,255,0.9), rgba(245,245,245,0.9)),
        no-repeat right 1.25rem center/18px;
    transition: all var(--transition-speed);
}

.kb-selector:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    background:
        linear-gradient(145deg, rgba(255,255,255,0.95), rgba(245,245,245,0.95)),
        url("data:image/svg+xml;charset=UTF-8,%3csvg...fill='%233DA09B'%3e...%3c/svg%3e")
        no-repeat right 1.25rem center/18px;
}

 .kb-selector:focus {
     box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2),
     0 12px 24px -8px rgba(67, 97, 238, 0.25);
     border-radius: 12px 12px 0 0;
 }

 .kb-selector option {
     padding: 12px 16px;
     margin: 4px 0;
     background: white;
     color: var(--text-dark);
     transition: all 0.2s ease;
     font-size: 0.95rem;
     position: relative;
     border-bottom: 1px solid rgba(0,0,0,0.05);
 }
 .kb-selector option:hover {
     background: rgba(67, 97, 238, 0.08) !important;
     transform: translateX(4px);
     box-shadow: 4px 0 0 var(--primary-color) inset;
 }
 .kb-selector option:checked {
     background: linear-gradient(
             90deg,
             rgba(67, 97, 238, 0.1) 0%,
             rgba(67, 97, 238, 0.05) 100%
     );
     font-weight: 500;
     color: var(--primary-color);
 }

 .kb-selector option[disabled]:first-child {
     color: #a0a0a0;
     font-style: italic;
     background: rgba(0,0,0,0.03);
 }
 .hidden {
     display: none;
 }
 .loader {
     display: inline-block;
     width: 24px;
     height: 24px;
     border: 3px solid #f3f3f3;
     border-radius: 50%;
     border-top-color: var(--primary-color);
     animation: spin 1s linear infinite;
 }
 .file-list {
     margin-top: 1rem;
     font-size: 0.9rem;
     color: var(--primary-color);
     max-width: 80%;
     margin-left: auto;
     margin-right: auto;
     word-break: break-all;
 }

 .confirm-overlay {
     position: fixed;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     background: rgba(0,0,0,0.5);
     z-index: 9999;
 }
 .confirm-box {
     position: fixed;
     top: 50%;
     left: 50%;
     transform: translate(-50%, -50%);
     background: white;
     padding: 2rem;
     border-radius: 16px;
     box-shadow: 0 8px 30px rgba(0,0,0,0.2);
     max-width: 400px;
     text-align: center;
     z-index: 10000;
     animation: slideIn 0.3s ease-out;
 }
 @keyframes slideIn {
     from {
         opacity: 0;
         transform: translate(-50%, -60%);
     }
     to {
         opacity: 1;
         transform: translate(-50%, -50%);
     }
 }

 .confirm-icon {
     width: 64px;
     height: 64px;
     margin: 0 auto 1.5rem;
     background: rgba(67, 97, 238, 0.1);
     border-radius: 50%;
     display: flex;
     align-items: center;
     justify-content: center;
 }
 .confirm-icon svg {
     width: 32px;
     height: 32px;
 }
 .confirm-title {
     font-size: 1.5rem;
     margin-bottom: 0.5rem;
     color: var(--text-dark);
 }
 .confirm-text {
     color: #666;
     margin-bottom: 2rem;
     line-height: 1.6;
 }
 .confirm-buttons {
     display: flex;
     gap: 1rem;
     justify-content: center;
 }
 .confirm-btn {
     padding: 0.75rem 2rem;
     border: none;
     border-radius: 8px;
     cursor: pointer;
     font-weight: 500;
     transition: all var(--transition-speed);
 }
 .confirm-btn-primary {
     background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
     color: white;
 }
 .cancel-btn {
     background: #f0f0f0;
     color: var(--text-dark);
 }
 .kb-name-section {
     margin: 1.5rem 0;
 }
 .kb-name-input:placeholder-shown {
     border-color: #e0e0e0;
     transition: all 0.3s ease;
 }
 .kb-name-input:not(:placeholder-shown) {
     border-color: var(--primary-color);
     box-shadow: 0 2px 8px rgba(67, 97, 238, 0.1);
 }
 .kb-name-label {
     display: block;
     font-size: 0.95rem;
     color: var(--text-dark);
     margin-bottom: 0.3rem;
     font-weight: 500;
     padding-left: 4px;
 }
 .kb-name-input::placeholder {
     color: #a0a0a0;
     opacity: 1;
 }
 .cancel-btn:hover {
     background: #e0e0e0;
 }

 .kb-selector optgroup {
     font-size: 0.85rem;
     color: #666;
     padding: 8px 16px;
     background: rgba(0,0,0,0.03);
     border-bottom: 1px solid #eee;
 }

 .kb-selector::-webkit-scrollbar {
     width: 8px;
     background: rgba(0,0,0,0.02);
 }
 .kb-selector::-webkit-scrollbar-thumb {
     background: rgba(67, 97, 238, 0.2);
     border-radius: 4px;
 }
 .kb-selector::-webkit-scrollbar-thumb:hover {
     background: var(--primary-color);
 }

 .kb-selector {
     transition: border-radius 0.2s ease;
 }
 .kb-selector:focus {
     border-radius: 12px 12px 0 0;
 }

 .kb-selector:hover {
     background-position: right 1rem center, 0 0;
 }

 .kb-selector:focus::after {
     content: "";
     position: absolute;
     top: 100%;
     left: -2px;
     right: -2px;
     height: 12px;
     background: white;
     z-index: -1;
 }

 .kb-selector option[disabled] {
     color: #999;
     background: rgba(0,0,0,0.02);
     cursor: not-allowed;
 }

 .kb-selector option::before {
     content: "•";
     color: var(--primary-color);
     margin-right: 8px;
     opacity: 0.6;
     transition: opacity 0.2s;
 }
 .kb-selector option:hover::before {
     opacity: 1;
 }
 @keyframes spin {
     to { transform: rotate(360deg); }
 }
 @media (max-width: 768px) {
     .document-info {
         flex-direction: column;
         gap: 1rem;
     }

     .info-item {
         border-right: none;
         border-bottom: 1px solid #eee;
         padding: 0.5rem 0;
         width: 100%;
     }

     .message {
         max-width: 85%;
     }

     .message-logo {
         width: 0px;
         height: 0px;
     }


     @keyframes messageSlide {
         from {
             opacity: 0;
             transform: translateX(var(--start-pos));
         }
         to {
             opacity: 1;
             transform: translateX(0);
         }
     }

     .bot-message {
         --start-pos: -200px;
         animation: messageSlide 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
     }

     .user-message {
         --start-pos: 20px;
         animation: messageSlide 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
     }
 }